package com.xinqi.modules.sys.appversion.controller.web;

import com.xinqi.common.base.response.R;
import com.xinqi.modules.sys.appversion.dto.req.AppVersionCreateDTO;
import com.xinqi.modules.sys.appversion.dto.req.AppVersionLatestQueryDTO;
import com.xinqi.modules.sys.appversion.dto.rsp.AppVersionResultDTO;
import com.xinqi.modules.sys.appversion.service.AppVersionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 版本记录列表WEB控制层
 *
 * @author: linkai
 * @date: 2023/04/27
 */
@Tag(name = "app-version-Web", description = "版本记录列表Web接口")
@RestController
@RequestMapping("/web/app-version")
@RequiredArgsConstructor
public class AppVersionWebController {
    private final AppVersionService appVersionService;


    /**
     * 查询最新版本
     */
    @PostMapping("/latestVersion")
    public R<AppVersionResultDTO> latestVersion(@Validated @RequestBody AppVersionLatestQueryDTO query) {
        return R.data(appVersionService.latestVersion(query));
    }

    /**
     * 新增版本
     */
    @Operation(summary = "新增版本")
    @PostMapping("/add")
    public R<Long> insert(@RequestBody AppVersionCreateDTO dto) {
        return R.data(appVersionService.insert(dto));
    }


}
